package club.vann.kafka.mock.util;

import com.cyberx.lunyu.Framework;

public class FrameWorkUtil {
  private FrameWorkUtil() {}

  /**
   * 获取错误码。
   *
   * @param dataStatus 数据状态
   * @return 错误码
   */
  public static Framework.ErrorCode ofErrorCode(Framework.DataStatus dataStatus) {
    return Framework.ErrorCode.newBuilder().setStatus(dataStatus).build();
  }

  /**
   * 获取时间记录。
   *
   * @return 时间记录
   */
  public static Framework.TimestampRecord ofTimestampRecord() {
    return ofTimestampRecord(System.currentTimeMillis());
  }

  /**
   * 获取时间记录。
   *
   * @param timestamp 时间戳
   * @return 时间记录
   */
  public static Framework.TimestampRecord ofTimestampRecord(long timestamp) {
    return Framework.TimestampRecord.newBuilder()
        .setAppReceive(timestamp)
        .setFirmReceive(timestamp)
        .setSrcPublish(timestamp)
        .setUpstreamPublish(timestamp)
        .build();
  }

  /**
   * 获取 bid/ask 对。
   *
   * @param bid Bid
   * @param ask Ask
   * @return BidAsk信息
   */
  public static Framework.BidAsk ofBidAsk(double bid, double ask) {
    return Framework.BidAsk.newBuilder().setBid(bid).setAsk(ask).build();
  }
}
